#include<iostream>
#include<string>
#include<cmath>
using namespace std;
typedef long long LL;
LL n;
string s;
int main()
{
	cin >> s;
	int cnt = s.size() - 1;
	for (int i = 0; i < s.size(); i++) {
		int k = s[i] - 'A' + 1;
		LL ans = (LL)pow(26, cnt);
		n += (LL)k * ans;
		cnt--;
	}
	cout << n << endl;
	return 0;
}